text = '''
<div>
    <ul>
        <li class="item-0"><a href="link1.html">first item</a></li>
        <li class="item-1"><a href="link2.html">second item</a></li>
        <li class="item-inactive"><a href="link3.html">third item</a></li>
        <li class="item-1"><a href="link4.html">fourth item</a></li>
        <li class="item-0"><a href="link5.html">fifth item</a></li>
    </ul>
</div>
'''

# xpath工具包
from lxml import etree

# 可以传网页html
html = etree.HTML(text) # 初始化操作 让xpath可以匹配上

href = html.xpath('//li/a/@href')

href3 = html.xpath('//li[@class="item-inactive"]/a/@href')

href3_data = html.xpath('//li[@class="item-inactive"]/a/text()')

print(href3_data)
